// 单例类
class Singleton {
    // 使用静态变量来存储单例实例
    private static final Singleton INSTANCE = new Singleton();

    // 私有构造函数，防止外部通过 new 关键字创建实例
    private Singleton() {
    }

    // 提供一个公共的静态方法，用于获取单例实例
    public static Singleton getInstance() {
        return INSTANCE;
    }

    // 示例方法
    public void showMessage() {
        System.out.println("This is a singleton instance.");
    }
}

// 测试类
public class Code6 {
    public static void main(String[] args) {
        // 获取单例实例
        Singleton singleton1 = Singleton.getInstance();
        Singleton singleton2 = Singleton.getInstance();

        // 验证两个实例是否相同
        System.out.println("Are singleton1 and singleton2 the same instance? " + (singleton1 == singleton2));

        // 调用示例方法
        singleton1.showMessage();
    }
}